package cn.ickck.law_paper_final.mapper;

import cn.ickck.law_paper_final.model.entity.CreditCardBatch;
import cn.ickck.law_paper_final.provider.CreditCardBatchProvider;
import cn.ickck.law_paper_final.provider.CreditCardProvider;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.UpdateProvider;

import java.util.List;

/**
 * @Author: ck
 * @Description:
 * @Date: Create in 18:06 2020/10/21
 */
public interface CreditCardBatchMapper {

    @Insert("insert into credit_card_batch(`name`, `num`, `key`,`date`) values( #{name}, #{num}, #{key},#{date})")
    int insert(CreditCardBatch creditCardBatch);

    @Select("select * from credit_card_batch")
    List<CreditCardBatch> findAll();

    @Delete("delete from credit_card_batch where id = #{id}")
    void deleteById(Integer id);

    @Select("select `key` from credit_card_batch where id = #{id}")
    CreditCardBatch findKeyById(Integer id);


    @UpdateProvider(type = CreditCardBatchProvider.class,method = "updateCreditCardBatch")
    void update(CreditCardBatch creditCardBatch);

    @Select("select count(*) from credit_card_batch")
    int count();

    @Select(
            "select * from credit_card_batch limit #{start},#{end}"
    )
    List<CreditCardBatch> findByPage(int start, int end);


    @Select("select * from credit_card_batch where name like  CONCAT('%',#{name},'%')")
    List<CreditCardBatch> findBatchByName(String name);
}
